#ifndef _N2F_RENDER_IW2D_TEXTFIELD_H_
#define _N2F_RENDER_IW2D_TEXTFIELD_H_

#include "..\..\core.h"
#include "..\..\Element.h"
#include "..\..\..\iw2d\h\Iw2D.h"
#include "..\..\Screen.h"
#include "Image.h"

enum N2FTextFieldState
{
	TextField_Idle,
	TextField_Active
};

enum N2FTextFieldMode
{
	TextField_Normal,
	TextField_MultiLine,
	TextField_Password
// Someday, add phone number, email, etc when we have greater
// access to the native keyboard libraries
};

enum N2FTextFieldFlags
{
	TextField_SquelchNewline = 1,
	TextField_SquelchNumbers = 2,
	TextField_SquelchCharacters = 4,
	TextField_SquelchSpecials = 8
};

namespace N2F
{
	namespace Iw3D
	{
		class TextField : public Element
		{
		public:
			typedef void (*OnFocusCallback)(void *, void *);
			typedef void (*OnBlurCallback)(void *, void *);
			typedef void (*OnKeyPressCallback)(InputKey *, void *);

		protected:
			struct FocusCallback
			{
				OnFocusCallback callback;
				void *userData;
			};

			struct BlurCallback
			{
				OnBlurCallback callback;
				void *userData;
			};

			struct KeyPressCallback
			{
				OnKeyPressCallback callback;
				void *userData;
			};

		public:
			TextField(const ScaleFactor &scaleFactor);
			~TextField();

			/*
			 *
			 * TextField *txtTest = new TextField(scaleFactor);
			 * txtTest->setBackgroundFile("Images/background.png");
			 * txtTest->setSize(CIwFVec2(100.0f, 150.0f));
			 * txtTest->setMode(TextField_Normal); // only do Normal atm
			 * txtTest->setFlags(TextField_SquelchNumbers | TextField_SquelchSpecials);
			 * txtTest->OnFocus(MyClass::OnTxtFocus, this);
			 * txtTest->OnBlur(MyClass::OnTxtBlur, this);
			 * txtTest->setMaxChars(120);
			 * 
			 */

			const char *getBackgroundFile() const;
			void setBackgroundFile(const char *file);

			const N2FTextFieldMode getMode() const;
			void setMode(N2FTextFieldMode mode);

			void setFlags(int flags);
			void setMaxChars(int maxChars);
			void setDefaultText(const char *text);

			const char *getText() const;
			void setText(const char *text);

			void OnFocus(OnFocusCallback callback, void *userData);
			void OnBlur(OnBlurCallback callback, void *userData);
			void OnKeyPress(OnKeyPressCallback callback, void *userData);

		protected:
			N2FTextFieldState state;
			N2FTextFieldMode mode;
			int flags, maxChars;
			std::string text;
		};
	}
}

#endif
